From a824da66d995c789a373ef2df627d06da34e973d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 15 Feb 2020 20:02:44 +0100 Subject: [PATCH] drop: Ensure all relevant formats are available 1. GdkDrop does deserialization, so add the deserialize formats 2. If the drop is local, we can copy straight from the drag, so we can also copy all its formats. This fixes cases where the backend would drop formats it doesn't support. --- gdk/gdkdrop.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gdk/gdkdrop.c b/gdk/gdkdrop.c index a0accf7464..9871d1c776 100644 --- a/gdk/gdkdrop.c +++ b/gdk/gdkdrop.c @@ -162,6 +162,23 @@ gdk_drop_read_local_finish (GdkDrop *self, return g_task_propagate_pointer (G_TASK (result), error); } +static void +gdk_drop_add_formats (GdkDrop *self, + GdkContentFormats *formats) +{ + GdkDropPrivate *priv = gdk_drop_get_instance_private (self); + + formats = gdk_content_formats_union_deserialize_gtypes (gdk_content_formats_ref (formats)); + + if (priv->formats) + { + formats = gdk_content_formats_union (formats, priv->formats); + gdk_content_formats_unref (priv->formats); + } + + priv->formats = formats; +} + static void gdk_drop_set_property (GObject *gobject, guint prop_id, @@ -186,10 +203,11 @@ gdk_drop_set_property (GObject *gobject, case PROP_DRAG: priv->drag = g_value_dup_object (value); + gdk_drop_add_formats (self, gdk_drag_get_formats (priv->drag)); break; case PROP_FORMATS: - priv->formats = g_value_dup_boxed (value); + gdk_drop_add_formats (self, g_value_get_boxed (value)); g_assert (priv->formats != NULL); break; -- 2.30.2